package com.alibaba.algo.components.permission.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.alibaba.algo.components.permission.auth.CheckAuthHandlerInterceptor;
import com.alibaba.algo.components.permission.interceptor.JwtTokenInterceptor;

/**
 * Created by IntelliJ IDEA.
 * User: glorysongglory
 * Date: 2020/10/28
 * Time: 14:39
 */
@Configuration
public class JwtInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private JwtTokenInterceptor jwtTokenInterceptor;
    
    @Autowired
    private CheckAuthHandlerInterceptor checkAuthHandlerInterceptor;
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //InterceptorRegistration registration = registry.addInterceptor(jwtTokenInterceptor);
    	InterceptorRegistration registration = registry.addInterceptor(checkAuthHandlerInterceptor);
        registration.addPathPatterns("/**").excludePathPatterns("/permission/login");
    }
}
